home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
simple7a
/
ftpbas.bas
< prev
next >
Wrap
BASIC Source File
|
1999-10-06
|
2KB
|
94 lines
Attribute VB_Name = "ftpbas"
Global IsGood As Boolean
Global PubData As Variant
Global User As String
Global Passwd As String
Global Host As String
Global Port As String
Global GoOnline As Boolean
Public Sub LogIn()
If Not GoOnline Then
Exit Sub
End If
DoEvents
On Error Resume Next
If User <> "" Then
frmMain.Inet1.Execute , "CLOSE"
While frmMain.Inet1.StillExecuting
DoEvents
Wend
End If
On Error GoTo 0
If Dir(App.Path & "\login.dat", vbNormal) = "" Then
MsgBox "No Login Data present!"
Exit Sub
End If
Open App.Path & "\login.dat" For Input As #1
Line Input #1, Host
Line Input #1, User
Line Input #1, Passwd
Line Input #1, Port
Close #1
frmMain.Label2.Caption = "Connecting to Host"
frmMain.Inet1.Protocol = icFTP
frmMain.Inet1.RemoteHost = Host
frmMain.Inet1.UserName = User
frmMain.Inet1.Password = Passwd
frmMain.Inet1.RemotePort = Port
frmMain.Inet1.RequestTimeout = 45
While frmMain.Inet1.StillExecuting
DoEvents
Wend
frmMain.Label2.Caption = "Connecting - Getting Files List"
While frmMain.Inet1.StillExecuting
DoEvents
Wend
On Error Resume Next
RefreshServer
frmMain.Label2.Caption = "File List Complete - Ready"
frmMain.Label4.Caption = Host
GoOnline = False
End Sub
Public Sub RefreshServer()
frmMain.List1.Clear
frmMain.Inet1.Execute , "LS"
tstErr = Err
If tstErr <> 0 Then
MsgBox Error(tstErr) & " - Closing FTP Connection"
frmMain.Label2.Caption = Error(tstErr)
frmMain.List1.Clear
On Error Resume Next
frmMain.Inet1.Cancel
If frmMain.Inet1.StillExecuting Then
DoEvents
End If
Exit Sub
End If
On Error GoTo 0
While frmMain.Inet1.StillExecuting
DoEvents
Wend
IsGood = True
PubData = ""
While IsGood
newdata = frmMain.Inet1.GetChunk(1024)
If Len(newdata) <> 0 Then
PubData = PubData & newdata
Else
IsGood = False
End If
Wend
myfiles = PubData
For i = 1 To Len(myfiles) - 1
k = InStr(i, myfiles, vbCrLf)
tmpfile = Mid(myfiles, i, k - i)
If Right(tmpfile, 1) = "/" Then
tmpfile = "*[" & Left(tmpfile, Len(tmpfile) - 1) & "]"
End If
frmMain.List1.AddItem tmpfile
i = k + 1
Next i
End Sub